package com.zhuss.controller.core;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.login.LoginBo;
import com.zhuss.bean.bo.core.login.LogoutBo;
import com.zhuss.bean.bo.core.login.UpdatePicBo;
import com.zhuss.bean.bo.core.login.UpdatePwdBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.LoginOperateService;
import com.zhuss.core.login.LoginServiceExt;
import com.zhuss.exception.AabException;


/**
 * 登录操作 controller
 * @Author zhushanshuo
   @Date 2019-12-27 19:58
 *
 */
  
 
@RestController
@RequestMapping("/login")
@Api(tags="PC端登录",value="PC端登录类")
public class LoginController extends BaseController {
	
	@Autowired
	@Qualifier("loginService")
	private LoginOperateService<Object, Object> loginService;
	
	@Autowired
	@Qualifier("loginServiceExt")
	private LoginServiceExt loginServiceExt;
	
	
	/**
	 * 登录
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/login")
	@ApiOperation(value="【PC端】登录", notes="用户名密码登录")
    public Object login(@RequestBody LoginBo bo) throws AabException {
		
		Object result = loginService.login(bo);
		return result;
    }
	
	
	/**
	 * 登出
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/logout")
	@ApiOperation(value="【PC端】登出", notes="登出")
    public void logout(@RequestBody LogoutBo bo) throws AabException {
		
		loginService.logout(bo);
    }
	
	/**
	 * 修改密码
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/pwdUpdate")
	@ApiOperation(value="【PC端】修改密码", notes="修改密码")
    public void pwdUpdate(@RequestBody UpdatePwdBo bo) throws AabException {
		
		loginServiceExt.updatePwd(bo);
    }
	
	/**
	 * 修改头像
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/picUpdate")
	@ApiOperation(value="【PC端】头像上传", notes="头像上传")
    public void picUpdate(@RequestBody UpdatePicBo bo) throws AabException {
		
		loginServiceExt.updatePic(bo);
    }

	
}
